<template>
  <div class="body">
    <div class="denglubox">
      <div class="denglutitle">疫情时期工程现场人员管理系统V1.0</div>
      <div class="input-box">
        <span class="user"></span>
        <input type="text" v-model="user.loginName" placeholder="用户名" />
      </div>
      <div class="input-box">
        <span class="mima"></span>
        <input type="password" v-model="user.password" placeholder="密码" />
      </div>
      <!-- <div class="input-box yzm">
        <input type="text" placeholder="验证码" />
        <input type="text" placeholder="NE95" />
      </div>-->
      <!-- <a href>忘记密码?</a> -->
      <button class="btn" @click="login">登录</button>
    </div>
  </div>
</template>
<style scoped>
.btn {
  cursor: pointer;
}
.body {
  width: 100%;
  height: 100%;
  position: fixed;
  background: url("../../assets/images/loginbg.png") no-repeat;
  background-size: 100% 100%;
  z-index: 999;
  top: 0;
  left: 0;
}
.input-box {
  /* width: 236px; */
  width: 291px;
  height: 38px;
  margin: 60px auto 0;
  display: flex;
  position: relative;
}
.input-box input {
  /* width: 212px; */
  width: 262px;
  height: 100%;
  border: 1px solid #0c248b;
  padding-left: 28px;
}
.input-box span {
  width: 24px;
  height: 24px;
  display: inline-block;
  position: absolute;
  top: 8px;
  left: 6px;
  z-index: 2;
}
.yzm input {
  width: 50%;
}
.body button {
  /* width: 236px; */
  width: 291px;
  height: 38px;
  background: #38a792;
  border: 1px solid #132b85;
  border-radius: 6px;
  margin: 0 auto;
  display: block;
  margin-top: 50px;
}
.user {
  background: url("../../assets/images/user.png") no-repeat;
  background-size: 100% 100%;
}
.mima {
  background: url("../../assets/images/mima.png") no-repeat;
  background-size: 100% 100%;
}
.denglubox {
  /* width: 300px;
  height: 318px; */
  width: 390px;
  height: 413.4px;
  background: url("../../assets/images/denglubg.png") no-repeat;
  background-size: 100% 100%;
  position: absolute;
  top: 50%;
  margin-top: -164px;
  right: 10%;
  padding-top: 10px;
}
.denglutitle {
  text-align: center;
  font-size: 24px;
  color: #fff;
  font-weight: bold;
  position: absolute;
  width: 100%;
  top: -50px;
  text-shadow: 1px 2px 0px #080808;
}
</style>
<script>
import { userlogin } from "../../service/login";
export default {
  data() {
    return {
      user: {
        loginName: "",
        password: ""
      }
    };
  },
  methods: {
    login() {
      const params = this.user;
      // window.console.log(params);
      if (this.user.loginName == "") {
        this.$message({
          message: "请输入用户名",
          type: "warning"
        });
      } else if (this.user.password == "") {
        this.$message({
          message: "请输入密码",
          type: "warning"
        });
      }
      userlogin(params).then(result => {
        if (result.data.status == 200) {
          window.sessionStorage.setItem("token", result.data.obj.token);
          window.sessionStorage.setItem("name", result.data.obj.name);
          window.sessionStorage.setItem("id", result.data.obj.id);
          this.$router.push({ path: `/epidemicRisk/`, replace: true });
          window.location.reload();
        } else {
          this.$message.error("登陆失败");
        }
      });
    }
  }
};
</script>